package com.wsoft.hr.pm.controller.sys;

import com.wsoft.hr.pm.query.sys.HrListQuery;
import com.wsoft.hr.pm.query.sys.MemberHrOrgQuery;
import com.wsoft.hr.pm.service.sys.IHrMemberOrgRelationService;
import com.wsoft.response.ResponseResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 *  前端控制器
 * @author zhanggukai
 * @since 2025年02月17日 15:36:40
 */
@RestController
@Tag(name = "绩效人员组织管理")
@RequestMapping("/hr/pm/memberOrgRelation")
public class HrMemberOrgRelationController {

    @Resource
    private IHrMemberOrgRelationService memberOrgRelationService;


    @Operation(summary = "添加人员组织关系",description = "添加人员组织关系")
    @PostMapping("/insert")
    public ResponseResult insert(@RequestBody @Valid MemberHrOrgQuery query) {
        memberOrgRelationService.insertRelation(query);
        return ResponseResult.success("[sys.msg.success]");
    }

    @Operation(summary = "删除人员组织关系",description = "删除人员组织关系")
    @GetMapping("/delete")
    public ResponseResult delete(@RequestParam("memberId") Long memberId) {
        memberOrgRelationService.deleteRelation(memberId);
        return ResponseResult.success("[sys.msg.success]");
    }

    @Operation(summary = "获取人员组织岗位关系列表",description = "获取人员组织岗位关系列表")
    @GetMapping("/get")
    public ResponseResult get(@RequestParam("memberId") Long memberId) {
        return ResponseResult.success(memberOrgRelationService.getMemberOrgRelation(memberId));
    }
    @Operation(summary = "根据绩效组织获取人员列表",description = "根据绩效组织获取人员列表")
    @PostMapping("/pageMember")
    public ResponseResult pageMember(@RequestBody @Valid HrListQuery query) {
        return ResponseResult.success(memberOrgRelationService.pageMember(query));
    }


}
